<div class="pull-left">
  <h4>Addresses</h4>
</div>
<div class="pull-right">
  <%= link_to 'Add new address', new_driver_address_path(@driver), :class => 'btn btn-mini btn-primary' %>
</div>
<table class="table table-bordered">
  <thead>
    <tr>
      <th> Default </th>
      <th> Address type </th>
      <th> Contact name </th>
      <th> Address </th>
      <th> Postal code </th>
      <th> City </th>
      <th> State </th>
      <th style="width: 100px;"> Action </th>
    </tr>
  </thead>
  <tbody>
    <% @driver.addresses.each do |address| %>
    <tr>
      <td> <% if @driver.default_address_id == address.id %> <span class="label label-success">Default</span> <% end %> </td>
      <td> <%= address.address_type.name rescue '' %> </td>
      <td> <%= address.contact_name_1 %> </td>
      <td> <%= address.address1 %> </td>
      <td> <%= address.postal_code %> </td>
      <td> <%= address.city.name rescue '' %> </td>
      <td> <%= address.state.name rescue '' %> </td>
      <td> <%= link_to 'Edit', edit_driver_address_path(@driver, address), :class => 'btn btn-mini btn-primary' %>
      <%= link_to 'Remove', driver_address_path(@driver, address), :confirm => 'Are you sure?', :method => :delete, :class => 'btn btn-mini btn-danger' %> </td>
    </tr>
    <% end %>
  </tbody>
</table>